# 使用list()函数创建列表
list_one = list([1])
list_two = list('python')
list_three = list([1,'python'])

# list_1 = [5,7,1,2,3]
# list_2 = sorted(list_1)
# print(list_1)
# print(list_2)

# # 使用索引访问列表元素
# list_3 = ['Python','Java','PHP']
# print(list_3[2])
# print(list_3[-2])

# num =input("请输入四个数字: ")
# list_num = []
# for i in num:
#     list_num.append(i)
#
# print(list_num)
# list_reverse = list(reversed(list_num))
# print(list_reverse)
# if(list_num ==list_reverse):
#     print()

# # 列表的遍历
# list_one = ['小明','小红','小花','小丽']
# print("今日促销通知!!!")
# for i in list_one:
#     print(f"您好,{i}!今日商城大促销，赶快来抢购吧！")

# # sort()方法
# li_one = [6,2,5,3]
# li_two = [7,3,5,4]
# li_three = ['Python','Java','PHP']
# li_one.sort()
# li_two.sort(reverse=True)
# li_three.sort(key=len)
# print(li_one)
# print(li_two)
# print(li_three)

# # sorted()方法
# li_one = [4, 3,2,1]
# li_two = sorted(li_one)
# print(li_one)
# print(li_two)

# # reverse()方法
# li_one = ['a','b','c','d']
# li_one.reverse()
# print(li_one)

# # 添加列表元素
# # append()方法
# list_one = [1,2,3,4]
# list_one.append(5)
# print(list_one)

# # extend()方法
# list_str = ['a','b','c']
# list_num = [1,2,3]
# list_str .extend((list_num))
# print(list_num)
# print(list_str)

# # insert()方法
# names = ['baby','lucy','alise']
# names.insert(2,'peter')
# print(names)

# #删除列表元素
# #del 语句
# names = ['小明','小红','小华','小花','小丽','小李']
# del names[0]
# print(names)
# del names[1:3]
# print(names)

# # remove()方法
# chars = ['h','e','l','l','e']
# chars.remove('e')
# print(chars)

# # pop()方法
# numbers = [1,2,3,4,5]
# numbers.pop()
# print(numbers)
# numbers.pop(1)
# print(numbers)

# #修改列表元素
# names = ['小明','小红','小华']
# names[0] = '小花'
# print(names)

# # 嵌套列表
# name_li = [['小明','小红'],['小花'],['小丽','小李']]
# print(name_li[0][0])

# name_li = [['小明','小红'],['小花'],['小丽','小李']]
# name_li[1].append('小王')
# print(name_li)

# # 元组的创建方式
# # 使用圆括号“（）”创建元组
# tu_one = ()
# tu_two = (1,)
# tu_three = ('t','u','p','l','e')
# tu_four = (0.3,1,'python',True)

# # 使用tuple（）函数创建元组
# tuple_null = tuple()
# print(tuple_null)
# tuple_str = tuple('abc')
# print(tuple_str)
# tuple_list = tuple([1,2,3])
# print(tuple_list)

# #访问元组元素
# # 使用索引访问单个元素
# tuple_demo = ('hello',100,'python')
# print(tuple_demo[0])
# print(tuple_demo[1])
# print(tuple_demo[2])

# 使用切片访问元组元素
exam_tuple = ('h','e','l','l','o')
print(exam_tuple[1:4])






